#include <netinet/in.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include "sockets.h"
#include <signal.h>
#include "ftp.h"
#include "linkList.cpp"

#define DUMP(a) { \
                    char *__tmp = a; \
                    while (*__tmp) { \
                        printf("0x%x ", *__tmp); \
                        __tmp++; \
                    } \
                    printf(" -> %s\n", a); \
                }

int memento() {
    std::cout << "Memento mori" << std::endl;
    return 0;
}

void posix_death_signal(int signum) {
    memento();
    signal(signum, SIG_DFL);
    exit(3);
}



int main() {
    signal(SIGSEGV, posix_death_signal);

    actLL *exam = new actLL;

    exam->add(5);
    exam->add(7);
    exam->add(2);
    exam->add(8);
    exam->add(0);
    exam->add(3);
    exam->add(1);
    exam->outPut();
    std::cout << "remove:" << std::endl;
    exam->rmLink(15);
    exam->actual = exam->actual->next;
    exam->outPut();
//    std::cout << "twice =):" << std::endl;
//    exam->outPut();



    exit(0);

//    ftp *ftpAction;
//    ftpAction = new ftp;

//    ftpAction->ftpCreateSocket();

//    while(true) ftpAction->ftpWaitConnection();

    return 0;
}

void actWithString() {
    char *str;
    str = new char[8];
    strcpy(str, "abcdefghijk");
    long *a;
    a = new long[3];
    a = (long*) str;
    //*a = 0x70717273;
    std::cout << "str = " << str << std::endl << "a = " << std::hex << a[0] << a[1] << a[2] << std::endl;


    a[1] = (a[1] << 24) | 0x202020;
    long b = a[1];
    char *str1;
    str1 = (char*) &b;
    std::cout << "str = " << str << std::endl << "str1 = " << str1 << std::endl << "a = " << std::hex << a[0] << a[1] << a[2] << std::endl;
    std::cout << "&str = " << &str << std::endl << "&a = " << &a << std::endl;
}
